package com.healthtop.web;

import com.healthtop.common.Page;
import com.healthtop.common.Views;
import com.healthtop.dto.XsDictionaryDto;
import com.healthtop.service.DIYService;
import com.healthtop.service.XsDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/xsDictionary")
public class XsDictionaryController {

    @Autowired
    private XsDictionaryService xsDictionaryService;

    @Autowired
    private DIYService diyService;

    @RequestMapping("/list")
    public String list(Page page){
        diyService.selectXsDictionaryList(page);
        return Views.XS_DICTIONARY_LIST;
    }

    @RequestMapping("/forward")
    public String forward(XsDictionaryDto xsDictionaryDto){
        xsDictionaryService.forward(xsDictionaryDto);
        return Views.XS_DICTIONARY_FORM;
    }

    @RequestMapping("/operate")
    public String operate(XsDictionaryDto xsDictionaryDto){
        xsDictionaryService.operate(xsDictionaryDto);
        return Views.REDIRECT_XS_DICTIONARY_LIST;
    }

    @RequestMapping("/delete")
    public String delete(long id){
        xsDictionaryService.delete(id);
        return Views.REDIRECT_XS_DICTIONARY_LIST;
    }
}
